package cn.tedu.springmvc.demo;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Controller控制层
 * ---@Controller注解：节约代码，控制层-
 *
 */
//用在类上，用于该类的所有控制器方法的访问路径的前缀使用
@RequestMapping("/my01")
@Controller
public class MyController01 {
    //    @RequestMapping("/test01.action")  错误示范
//    public void test01(){
//        System.out.println("你好，helloSpringMVC");
//    }
    @RequestMapping("/test01.action")
    public ModelAndView test01(){
        ModelAndView mav=new ModelAndView();
        mav.addObject("k1","hello");
        mav.addObject("k2","Springmvc");
        mav.setViewName("test01");  //返回文件  test01.jsp  --
        return  mav;
    }
    @RequestMapping("/test02.action")
    public ModelAndView test02(){
        ModelAndView mav=new ModelAndView();
        mav.addObject("k1","hello");
        mav.addObject("k2","Springmvc");
        mav.setViewName("test02");  //返回文件  test01.jsp
        return  mav;
    }
}
